<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=s, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let url = 'http://www.shidazhi.cn/index.html?1x=1&name=zhufeng&teacher=aaa#box'
        function queryURLParams(url) {
            let askIndex = url.indexOf('?')
            let wellIndex = url.indexOf('#')
            let askText = ''
            let wellText = ''
            let obj = {}
            //#不存在
            wellIndex == -1 ? wellIndex = url.length : null

            //?存在
            askIndex != -1 ? askText = url.substring(askIndex + 1, wellIndex) : null

            wellText = url.substring(wellIndex + 1)

            wellText != '' ? obj.HASH = wellText : null

            if (askText != '') {

                let askAry = askText.split('&')
                askAry.forEach((item, index) => {
                    let n = item.split('=')
                    let j = n[0]
                    let k = n[1]
                    obj[j] = k
                })

            }
            return obj

        }
        console.log(queryURLParams(url));
    </script>
</body>

</html>